n = 16
step = 0
rods = {}


def create_rods(n):
    rods['A'] = list(range(n, 0, -1))
    rods['B'] = []
    rods['C'] = []


def move(x, y):
    global step
    step += 1
    print(f"第{step}步：将{rods[x][-1]}从{x}移动到{y}")
    rods[y].append(rods[x].pop())


# 把n个圆盘从a移动到c，b为中介
def solve(n, a, b, c):
    if n == 1:
        move(a, c)
    else:
        # 把n-1个圆盘从a移动到b，c为中介
        solve(n-1, a, c, b)
        # 把直径为n圆盘从a移动到c
        move(a, c)
        # 把n-1个圆盘从b移动到c，a为中介
        solve(n-1, b, a, c)


def main():
    create_rods(n)
    solve(n, 'A', 'B', 'C')
    print(rods)


main()
